<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>阴影绘制</title>
  <style>
    canvas {
      display: block;
      border: 1px solid #000;
      margin: 0 auto;
    }
  </style>
</head>

<body>
  <canvas id="myCanvas" width="600" height="600"></canvas>

  <script>
    const canvas = document.getElementById("myCanvas");
    const ctx = canvas.getContext("2d");

    // 阴影绘制
    if (true) {
      ctx.font = "30px 微软雅黑";
      // 左右偏移
      ctx.shadowOffsetX = -3;
      // 上下偏移
      ctx.shadowOffsetY = 3;
      // 模糊程度
      ctx.shadowBlur = 2;
      // 阴影颜色
      ctx.shadowColor = "gray";

      ctx.fillText("欢迎来到canvas的世界", 100, 100);
    }

  </script>
</body>

</html>